<!--KTV订单管理 -->
<template>
  <div class="admin-body">
    <el-row>
      <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item  :to="{ path: '/kTVShop' }"><span style="color: #409eff">{{this.$store.state.login.ktvShopData.name}}</span></el-breadcrumb-item>
        <el-breadcrumb-item >订单详情</el-breadcrumb-item>
      </el-breadcrumb>
    </el-row>
    <el-row style="padding: 15px">

      <el-row class="main">
        <el-row  style="min-height: 40px;display: flex;">
          <el-col  style="margin-bottom: 5px;" align="left">
            <el-radio-group v-model="type" @change="test()">
              <el-radio-button label="1">订单</el-radio-button>
              <el-radio-button label="2">已取消订单</el-radio-button>
            </el-radio-group>
            <el-input v-model="key" clearable style="width: 300px;margin-left: 20px;" placeholder="输入关键词查询" class="kz_search">
              <el-button slot="append" type="primary"  @click="getstart()">搜索</el-button>
            </el-input>
          </el-col>
          <!--<el-col  style="margin-bottom: 5px;" align="left">-->

          <!--</el-col>-->
        </el-row>
        <!--表格-->
        <el-table
          select-on-indeterminate
          ref="multipleTable"
          border
          align="left"
          :data="tableData">
          <el-table-column
            type="index"
            label="序号"
            width="50">
          </el-table-column>
          <el-table-column
            prop="nickname"
            label="下单人昵称">
          </el-table-column>
          <el-table-column
            prop="phone"
            label="电话号码">
          </el-table-column>
          <el-table-column
            prop="ordernum"
            label="订单号">
          </el-table-column>
          <el-table-column
            label="时间段">
            <template slot-scope="scope">
              {{scope.row.start_time}} - {{scope.row.over_time}}
            </template>
          </el-table-column>
          <el-table-column
            label="包房类型">
            <template slot-scope="scope">
              {{pdlx(scope.row.type)}}
            </template>
          </el-table-column>
          <el-table-column
            label="场次">
            <template slot-scope="scope">
              {{pdlx2(scope.row.type)}}
            </template>
          </el-table-column>
          <el-table-column
            prop="people"
            label="预订人数">
          </el-table-column>
          <el-table-column
            prop="price"
            label="预订价格">
          </el-table-column>
          <el-table-column
            v-if="type == 1"
            fixed="right"
            label="核销时间">
            <template slot-scope="scope">
              {{formatDate(scope.row.use_time)}}
            </template>
          </el-table-column>
          <el-table-column
            v-if="type == 2"
            fixed="right"
            label="订单取消时间">
            <template slot-scope="scope">
              {{formatDate(scope.row.addtime)}}
            </template>
          </el-table-column>
        </el-table>
        <!--分页-->
        <el-row style="margin-top: 20px">
          <el-col :xs="24" :sm="24" :md="24" :lg="24" align="right">
            <el-pagination
              style="text-align: right;margin-bottom:70px;"
              background
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="page"
              :page-sizes="[10, 20, 50, 100]"
              :page-size="pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="dataTotal">
            </el-pagination>
          </el-col>
        </el-row>
      </el-row>
    </el-row>
    <el-dialog title="新增" :visible.sync="addVisible" width="360px" :modal-append-to-body="false">
      <el-form :model="adddata" :rules="addrules" ref="adddata">
        <el-form-item label="名称：" :label-width="formLabelWidth" prop="user_name">
          <el-input v-model="adddata.user_name" clearable></el-input>
        </el-form-item>
        <el-form-item label="账号：" :label-width="formLabelWidth" prop="user_account">
          <el-input  v-model="adddata.user_account"  clearable></el-input>
        </el-form-item>
        <el-form-item label="密码：" :label-width="formLabelWidth" prop="user_password">
          <el-input v-model="adddata.user_password"  type="password" clearable></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="SubmitAdd()">确 定</el-button>
        <el-button @click="addVisible = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: "KTVOrder",
    mounted() {
      if (!this.$store.state.login.in) {
        this.$router.push({name: "login", params: {userId: 123}})
      }
      this.getstart()
    },
    data() {
      return {
        pageSize: 10,
        page: 1,
        dataTotal: 0,
        tableData:[],
        addVisible:false,
        formLabelWidth:'80px',
        adddata:{
          user_account:'',
        },
        addrules:{
          user_account: [
            {required: true, message: '请输入账号', trigger: 'blur'}
          ],
        },
        key:'',
        type:1,

      }
    },
    methods: {
      pdlx(type){
        let dateArr = ['小包','中小包','大包','豪包',];
        return dateArr[type]
      },
      pdlx2(type){
        let dateArr = ['上午场','下午场','黄金场','午夜场',];
        return dateArr[type]
      },
      test(){
        this.page = 1
        this.getstart()
      },
      add(){
        this.addVisible = true
      },
      //绑定表格数据，分页
      getstart() {
        let thi = this
        const prams = {
          page:thi.page,
          pageSize:thi.pageSize,
          key:thi.key,
          type:thi.type,
          shop_id:thi.$store.state.login.ktvShopData.shop_id,
        }
        thi.mySelectAll('platformOrderList',prams).then(function (value) {
          thi.tableData = value.data
          thi.dataTotal = value.Total
        })
      },

      //选择展示数量
      handleSizeChange(val) {
        this.pageSize = val
        this.getstart()
      },
      //分页
      handleCurrentChange(val) {
        this.page = val
        this.getstart()
      },
      //状态改变提示
      changeMes(id, state) {
        var heeh = '该'
        var caozuo = '禁用'
        if (id.length > 1) {
          heeh = '这些'
        }
        if (state == 0) {
          caozuo = '删除'
        }
        let thi = this
        thi.$confirm('此操作将'+caozuo + heeh+'平台', '是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'error'
        }).then(() => {
          thi.submitState(id,state)
        }).catch(() => {
          thi.$message({
            type: 'info',
            message: '已取消'
          });
        });
      },
      //删除
      submitState(id,state) {
        let thi = this
        const por = {
          platform_id: id,
          state: state,
        }
        console.log(por)
        thi.mySubmit('platformState', por).then(function (code) {
          if (code == 200) {
            thi.getstart()
          }
        })
      },
    }
  }

</script>

<style scoped>
  .main {
    background-color: white;
    min-height: 500px;
    padding: 10px;
    border: #EDEDED 1px solid;
    border-radius: 5px;
  }
  .el-row{
    /*防止页面抖动*/
    width: calc(100% - 2px) !important;
  }
</style>
